package com.hex.ds.hdrs.app.dao;


import com.hex.bigdata.hbda.base.BaseDao;
import com.hex.bigdata.hbda.base.Page;
import com.hex.ds.hdrs.app.dto.AppConfDto;
import com.hex.ds.hdrs.app.po.AppConf;
import com.hex.ds.hdrs.app.vo.AppConfVo;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class AppConfDao extends BaseDao {

    public AppConf qryAppConfByAppCode(String appCode) {
        return this.selectOne(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qryAppConfByAppCode", appCode);
    }

    public List<AppConf> qryAppConfByAgentCode(String agentCode) {
        return this.selectList(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qryAppConfByAgentCode", agentCode);
    }

    public List<AppConf> qryAppConfList() {
        return this.selectList(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qryAppConfList");
    }

    /**
     * 分页查询
     *
     * @param map
     * @param page
     * @return
     */
    public List<AppConfVo> selectPages(Map map, Page page) {
        return this.selectPage(AppConfVo.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qry", page, map);
    }

    /**
     * 应用新增
     *
     * @param appConf
     * @return
     */
    public int add(AppConf appConf) {
        return this.insert("com.hex.ds.hdrs.app.dao.AppConfDao.insert", appConf);
    }

    /**
     * 应用删除
     *
     * @param pkId
     */
    public void del(String pkId) {
        this.delete("com.hex.ds.hdrs.app.dao.AppConfDao.delete", pkId);
    }

    /**
     * 节点名称查询
     *
     * @return
     */
    public List<AppConf> qryCodeName() {
        return this.selectList(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qryCodeName");
    }

    /**
     * 修改应用状态
     *
     * @param appConf
     * @return
     */
    public int editAppSatus(AppConf appConf) {
        return this.update("com.hex.ds.hdrs.app.dao.AppConfDao.editAppSatus", appConf);
    }

    /**
     * 通过id查询应用信息
     *
     * @param map
     * @return
     */
    public AppConfDto qryAppConfDto(Map map) {
        return this.selectOne(AppConfDto.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qryAppConfDto", map);
    }

    public int edit(AppConf appConf) {
        return this.update("com.hex.ds.hdrs.app.dao.AppConfDao.update", appConf);
    }

    public List<AppConf> findAppByCurrentUser(String username) {
        return this.selectList(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.findAppByCurrentUser", username);
    }

    public List<String> findAppCodeByUser(String username) {
        return this.selectList(String.class, "com.hex.ds.hdrs.app.dao.AppConfDao.findAppCodeByUser", username);
    }

    public AppConf getAppConf(Map map) {
        return this.selectOne(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.getAppConf", map);
    }

    public AppConfVo findAppInfoByAppCode(String appCode) {
        return this.selectOne(AppConfVo.class, "com.hex.ds.hdrs.app.dao.AppConfDao.findAppInfoByAppCode", appCode);
    }

    public List<AppConf> findAppByGroupCode(String groupCode) {
        return this.selectList(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.findAppByGroupCode", groupCode);

    }
    public List<AppConf> findCodeByName(String appName) {
        return this.selectList(AppConf.class, "com.hex.ds.hdrs.app.dao.AppConfDao.findCodeByName", appName);

    }

    public Integer qryAppCount(Map map) {
        return this.selectOne(Integer.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qryAppCount", map);
    }

    public int qryConcurrentNum(){
        return this.selectOne(Integer.class, "com.hex.ds.hdrs.app.dao.AppConfDao.qryConcurrentNum", null);
    }

    public List<AppConf> findAppConfListByCurrentUser(Map map) {
        return this.selectList(AppConf.class,"com.hex.ds.hdrs.app.dao.AppConfDao.findAppConfListByCurrentUser",map);
    }
}